<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
	<title>6.270 - JoyOS: lcd.h File Reference</title>
	<link href="main.css" media="screen" rel="Stylesheet" type="text/css"/>
	<link href="doxygen.css" rel="stylesheet" type="text/css">
</head>  
<body>
	<div id="header">
		<div id="headerb">
		<div id="headtext">
			<span class="titletext">AUTONOMOUS ROBOT DESIGN COMPETITION</span>
			6.270
		</div>
		<div class="mainmenu">
			<a href="http://web.mit.edu/6.270/www">Home</a>
		 	&bull;
			<a href="http://web.mit.edu/6.270/www/about/">About</a> 
		 	&bull;
			<a href="http://web.mit.edu/6.270/www/sponsors/">Sponsors</a>
		 	&bull;
			<a href="http://web.mit.edu/6.270/www/contests/">Past Contests</a> 
		 	&bull;
			<a href="http://web.mit.edu/6.270/www/contestants/">Contestant Information</a>
		</div>
	</div>
	</div>

<div class="maincontent">
<!-- Generated by Doxygen 1.5.1 -->
<div class="tabs">
  <ul>
    <li><a href="index.html"><span>Main&nbsp;Page</span></a></li>
    <li><a href="annotated.html"><span>Data&nbsp;Structures</span></a></li>
    <li id="current"><a href="files.html"><span>Files</span></a></li>
  </ul></div>
<div class="tabs">
  <ul>
    <li><a href="files.html"><span>File&nbsp;List</span></a></li>
    <li><a href="globals.html"><span>Globals</span></a></li>
  </ul></div>
<h1>lcd.h File Reference</h1>LCD control, formatting, printout. <a href="#_details">More...</a>
<p>
<code>#include &lt;inttypes.h&gt;</code><br>
<code>#include &lt;stdio.h&gt;</code><br>
<code>#include &lt;avr/pgmspace.h&gt;</code><br>
<table border="0" cellpadding="0" cellspacing="0">
<tr><td></td></tr>
<tr><td colspan="2"><br><h2>Functions</h2></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">void&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="lcd_8h.html#6842775ba83d166f02b8fef8bb63b1e6">lcd_init</a> (void)</td></tr>

<tr><td class="memItemLeft" nowrap align="right" valign="top">void&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="lcd_8h.html#a4e7d14129acc8828210d8b2734d8d53">lcd_set_custom_char</a> (uint8_t chnum, uint8_t *data)</td></tr>

<tr><td class="memItemLeft" nowrap align="right" valign="top">void&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="lcd_8h.html#9958d5441d79af42a23a03f6229de09d">lcd_write_data</a> (uint8_t data)</td></tr>

<tr><td class="memItemLeft" nowrap align="right" valign="top">void&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="lcd_8h.html#8e797193c9078dc7e540a38f67a19c9e">lcd_print</a> (const char *string)</td></tr>

<tr><td class="memItemLeft" nowrap align="right" valign="top">int&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="lcd_8h.html#48e09d38aa00e38402d50e6df04bae45">lcd_vprintf</a> (const char *fmt, va_list ap)</td></tr>

<tr><td class="memItemLeft" nowrap align="right" valign="top">int&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="lcd_8h.html#b8da66cae6bb1d79a1ccea75377ffa18">lcd_printf</a> (const char *fmt,...)</td></tr>

<tr><td class="memItemLeft" nowrap align="right" valign="top">int&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="lcd_8h.html#5cf8a673103fff0d56f52e6f45b6b8e6">lcd_print_char</a> (char ch, FILE *f)</td></tr>

<tr><td class="memItemLeft" nowrap align="right" valign="top">void&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="lcd_8h.html#d235a86241458b1e7b8771688bfdaf9a">lcd_clear</a> (void)</td></tr>

<tr><td class="memItemLeft" nowrap align="right" valign="top">uint8_t&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="lcd_8h.html#d842e0294e974e5bb18da006504ec002">lcd_get_pos</a> (void)</td></tr>

<tr><td class="memItemLeft" nowrap align="right" valign="top">void&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="lcd_8h.html#3799f34557445524c2ab33ffe663d26d">lcd_set_pos</a> (uint8_t p)</td></tr>

</table>
<hr><a name="_details"></a><h2>Detailed Description</h2>
The happyboard LCD is a 2x16 character device. The OS code treats the LCD as a single 1x32 line display. This means that printf("012345690123456789") will display:<p>
<div class="fragment"><pre class="fragment">         +----------------+
 line 1: |0123456789012345|
 line 2: |6789            |
         +----------------+
</pre></div><p>
For general LCD printing, printf() is suggested. printf() is a wrapper around the functions documented below. As such these functions should only be used when printf() is insufficient.<p>
Printing a newline character ("\n" in C) to the display clears it. Thus, printf("hello world\n"), will not display anything (the display is cleared after the text is displayed). Instead, you should use printf("\nhello world")<ul>
<li>this will clear the display and then display the text.</li></ul>
<p>
The OS will occasionally use the bottom right character of the display for warning/information icons, which may obscure user printouts (if they use the full 32 characters of the display).<p>
The LCD supports 8 user-defined characters. On startup these characters are set to a system defaults as follows:<p>
<div class="fragment"><pre class="fragment"> 0: unsused
 1: smiley face
 2: alternate smiley face
 3: frowny face
 4: low battery indicator
 5: loading indicator
 6: bootloader indicator
 7: unused
</pre></div><p>
These special characters can be reconfigured by the user with the <a class="el" href="lcd_8h.html#a4e7d14129acc8828210d8b2734d8d53">lcd_set_custom_char()</a> function, as long as you remember this will change the OS warning indicator icons. <hr><h2>Function Documentation</h2>
<a class="anchor" name="d235a86241458b1e7b8771688bfdaf9a"></a><!-- doxytag: member="lcd.h::lcd_clear" ref="d235a86241458b1e7b8771688bfdaf9a" args="(void)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void lcd_clear           </td>
          <td>(</td>
          <td class="paramtype">void&nbsp;</td>
          <td class="paramname">          </td>
          <td>&nbsp;)&nbsp;</td>
          <td width="100%"></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>
Clear the LCD Screen. 
</div>
</div><p>
<a class="anchor" name="d842e0294e974e5bb18da006504ec002"></a><!-- doxytag: member="lcd.h::lcd_get_pos" ref="d842e0294e974e5bb18da006504ec002" args="(void)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">uint8_t lcd_get_pos           </td>
          <td>(</td>
          <td class="paramtype">void&nbsp;</td>
          <td class="paramname">          </td>
          <td>&nbsp;)&nbsp;</td>
          <td width="100%"></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>
Return the current cursor position. 
</div>
</div><p>
<a class="anchor" name="6842775ba83d166f02b8fef8bb63b1e6"></a><!-- doxytag: member="lcd.h::lcd_init" ref="6842775ba83d166f02b8fef8bb63b1e6" args="(void)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void lcd_init           </td>
          <td>(</td>
          <td class="paramtype">void&nbsp;</td>
          <td class="paramname">          </td>
          <td>&nbsp;)&nbsp;</td>
          <td width="100%"></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>
Initialise the LCD driver 
</div>
</div><p>
<a class="anchor" name="8e797193c9078dc7e540a38f67a19c9e"></a><!-- doxytag: member="lcd.h::lcd_print" ref="8e797193c9078dc7e540a38f67a19c9e" args="(const char *string)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void lcd_print           </td>
          <td>(</td>
          <td class="paramtype">const char *&nbsp;</td>
          <td class="paramname"> <em>string</em>          </td>
          <td>&nbsp;)&nbsp;</td>
          <td width="100%"></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>
Display a string to the LCD.<p>
<dl compact><dt><b>Parameters:</b></dt><dd>
  <table border="0" cellspacing="2" cellpadding="0">
    <tr><td valign="top"></td><td valign="top"><em>string</em>&nbsp;</td><td>string to display </td></tr>
  </table>
</dl>

</div>
</div><p>
<a class="anchor" name="5cf8a673103fff0d56f52e6f45b6b8e6"></a><!-- doxytag: member="lcd.h::lcd_print_char" ref="5cf8a673103fff0d56f52e6f45b6b8e6" args="(char ch, FILE *f)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">int lcd_print_char           </td>
          <td>(</td>
          <td class="paramtype">char&nbsp;</td>
          <td class="paramname"> <em>ch</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">FILE *&nbsp;</td>
          <td class="paramname"> <em>f</em></td><td>&nbsp;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td><td width="100%"></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>
Print a single character to the LCD.<p>
<dl compact><dt><b>Parameters:</b></dt><dd>
  <table border="0" cellspacing="2" cellpadding="0">
    <tr><td valign="top"></td><td valign="top"><em>ch</em>&nbsp;</td><td>character to display </td></tr>
    <tr><td valign="top"></td><td valign="top"><em>f</em>&nbsp;</td><td>ignored </td></tr>
  </table>
</dl>

</div>
</div><p>
<a class="anchor" name="b8da66cae6bb1d79a1ccea75377ffa18"></a><!-- doxytag: member="lcd.h::lcd_printf" ref="b8da66cae6bb1d79a1ccea75377ffa18" args="(const char *fmt,...)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">int lcd_printf           </td>
          <td>(</td>
          <td class="paramtype">const char *&nbsp;</td>
          <td class="paramname"> <em>fmt</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">&nbsp;</td>
          <td class="paramname"> <em>...</em></td><td>&nbsp;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td><td width="100%"></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>
Display a formated string to the LCD.<p>
<dl compact><dt><b>Parameters:</b></dt><dd>
  <table border="0" cellspacing="2" cellpadding="0">
    <tr><td valign="top"></td><td valign="top"><em>fmt</em>&nbsp;</td><td>format to display </td></tr>
  </table>
</dl>

</div>
</div><p>
<a class="anchor" name="a4e7d14129acc8828210d8b2734d8d53"></a><!-- doxytag: member="lcd.h::lcd_set_custom_char" ref="a4e7d14129acc8828210d8b2734d8d53" args="(uint8_t chnum, uint8_t *data)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void lcd_set_custom_char           </td>
          <td>(</td>
          <td class="paramtype">uint8_t&nbsp;</td>
          <td class="paramname"> <em>chnum</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">uint8_t *&nbsp;</td>
          <td class="paramname"> <em>data</em></td><td>&nbsp;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td><td width="100%"></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>
Sets a custom LCD character. The LCD has space for 8 custom characters (characters 0-7.) Note that the OS uses some of these charaters for the status indicator. The data is read from program (flash) memory and therefore should be defined as PROGMEM, eg: <div class="fragment"><pre class="fragment"> uint8_t my_custom_char[] PROGMEM = { 12, 23, 34, 45, 56, 67, 78, 89 };
</pre></div><p>
<dl compact><dt><b>Parameters:</b></dt><dd>
  <table border="0" cellspacing="2" cellpadding="0">
    <tr><td valign="top"></td><td valign="top"><em>chnum</em>&nbsp;</td><td>character to set </td></tr>
    <tr><td valign="top"></td><td valign="top"><em>data</em>&nbsp;</td><td>8 byte array of pixel data </td></tr>
  </table>
</dl>

</div>
</div><p>
<a class="anchor" name="3799f34557445524c2ab33ffe663d26d"></a><!-- doxytag: member="lcd.h::lcd_set_pos" ref="3799f34557445524c2ab33ffe663d26d" args="(uint8_t p)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void lcd_set_pos           </td>
          <td>(</td>
          <td class="paramtype">uint8_t&nbsp;</td>
          <td class="paramname"> <em>p</em>          </td>
          <td>&nbsp;)&nbsp;</td>
          <td width="100%"></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>
Set the current cursor position.<p>
<dl compact><dt><b>Parameters:</b></dt><dd>
  <table border="0" cellspacing="2" cellpadding="0">
    <tr><td valign="top"></td><td valign="top"><em>p</em>&nbsp;</td><td>position to move to [0..31] </td></tr>
  </table>
</dl>

</div>
</div><p>
<a class="anchor" name="48e09d38aa00e38402d50e6df04bae45"></a><!-- doxytag: member="lcd.h::lcd_vprintf" ref="48e09d38aa00e38402d50e6df04bae45" args="(const char *fmt, va_list ap)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">int lcd_vprintf           </td>
          <td>(</td>
          <td class="paramtype">const char *&nbsp;</td>
          <td class="paramname"> <em>fmt</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">va_list&nbsp;</td>
          <td class="paramname"> <em>ap</em></td><td>&nbsp;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td><td width="100%"></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>
Display a formated string to the LCD.<p>
<dl compact><dt><b>Parameters:</b></dt><dd>
  <table border="0" cellspacing="2" cellpadding="0">
    <tr><td valign="top"></td><td valign="top"><em>fmt</em>&nbsp;</td><td>format to display </td></tr>
    <tr><td valign="top"></td><td valign="top"><em>ap</em>&nbsp;</td><td>virtual argument list </td></tr>
  </table>
</dl>

</div>
</div><p>
<a class="anchor" name="9958d5441d79af42a23a03f6229de09d"></a><!-- doxytag: member="lcd.h::lcd_write_data" ref="9958d5441d79af42a23a03f6229de09d" args="(uint8_t data)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void lcd_write_data           </td>
          <td>(</td>
          <td class="paramtype">uint8_t&nbsp;</td>
          <td class="paramname"> <em>data</em>          </td>
          <td>&nbsp;)&nbsp;</td>
          <td width="100%"></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>
Write a data byte to the LCD. Should not normally be needed by user code.<p>
<dl compact><dt><b>Parameters:</b></dt><dd>
  <table border="0" cellspacing="2" cellpadding="0">
    <tr><td valign="top"></td><td valign="top"><em>data</em>&nbsp;</td><td>byte to write. </td></tr>
  </table>
</dl>

</div>
</div><p>
</div>
<div class="maincontent">
	<div class="footer centre">
		<hr>
		Generated on Tue Jan 29 23:17:08 2008 by&nbsp;<a href="http://www.doxygen.org/index.html">Doxygen</a> 1.5.1<br/>
		6.270 Staff, 2008 | 
		<a href="mailto:6.270-organizers@mit.edu">Contact Us</a> | 
		<a href="http://web.mit.edu">MIT</a>
	</div>
</div>
</body>
</html>
